SliderCDEF is a control definition function for a slider with a simple indicator and a track without arrows on the end. The slider uses offscreen graphics worlds to give smooth animation of the thumb as it is dragged around the track.
This version is an improvement over an earlier one posted on alt.sources.mac. This version handles vertical configurations, disabled states, and changing monitor depths. Also, dragging has been improved and several small bugs have been fixed. The code is easy to read and well documented and could be easily modified for more specific needs.
The archive contains source code, a resource file containing the CDEF, and a small demonstration application. The archive is Stuffit 3.0 and has been binhexed.
VARIATION CODES
----------------
The variation codes are masks similar to those used for popup control variations. They can be added together to get combinations of features. Some combinations are not allowed, however. Here is a list of possible combinations:
0
Just a plain slider.
1
Draws the value of the control centered above the indicator or to the right of the indicator if the slider is horizontal or vertical, respectively. The value is drawn outside the control's rectangle, so room must be left there for it.
3 (2+1)
Draws the value similar to variation code 1, but with the slider's title appended to the value.
5 (4+1)
Draws the value similar to variation code 1, but with the slider's title prefixed before the value.
8
Draws the slider's title inside the track.
9 (8+1)
Draws the slider's title inside the track and the value centered above the thumb.
REQUIREMENTS
-------------
The slider requires the use of GWorlds and doesn't check itself. This requirement must be tested for by the main program before attempting to use SliderCDEF.
KNOWN PROBLEMS
----------------
(1) Doesn't yet support a slop rect for dragging.
(2) Some thumb lengths do not draw properly.
If anyone fixes these or other problems, please send me the results and I'll incorporate it into future releases.
RESTRICTIONS
-------------
SliderCDEF is provided free of charge, however if you do use it in a piece of software or make significant improvements, I'd like to hear about it and see the results. The only required conditions for use are (1) that this agreement is non-exclusive, and (2) that I, Harold Ekstrom, retain the copyright to the original source code. The following requests are not required for the use of SliderCDEF: (1) that I be given credits for SliderCDEF in the copyrights or acknowledgements section of your manual or other appropriate documentation, and (2) that you send me the name of any package that the Slider CDEF is used in and that I be granted to use this information in a list of applications using SliderCDEF.
LEGAL STUFF
-----------
Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the copyright notice appears in all copies (of the source). This software is provided "as is" without express or implied warranty.
ACKNOWLEDGMENTS
---------------
Thanks to the following people for their suggestions and help: Mahboud Zabetian, Pace Bonner, Brian Stern, and Mike Russell.
Harold Ekstrom
Internet: ekstrom@aggoup.com (preferred)
Voice: (510) 937-7900
U.S. Mail: 2540 Camino Diablo, Suite 200
Walnut Creek, CA 94596
VERSION HISTORY
===============
SliderCDEF 1.3.0
----------------
• (11/20/94) Changed variation codes to make combinations possible. Added a variation with the control title within the track.
SliderCDEF 1.2.7
----------------
• (11/12/94) Fixed the dragging routine thumb pinning algorithm.
SliderCDEF 1.2.6
----------------
• (10/25/94) Moved the grabbing of the start point in the drag routine to the top of the function (doesn't seem to help).
• (10/14/94) Fixed a problem where the thumb was initially drawn at the zero position.
SliderCDEF 1.2.5
----------------
• (9/27/94) Changed the way the slider keeps track of the thumb position and completely changed the slider's private data structure. The slider now uses two GWorlds for the thumb and track. The dragging code was completely rewritten.
• (9/26/94) Changed the color scheme to use the control's auxiliary color table.
SliderCDEF 1.2.3 - 1.2.4
------------------------
• (8/19/94) Test versions, not released.
SliderCDEF 1.2.2
----------------
• (6/29/94) Fixed drawing of values - drawing now limited to the intersection of the port's clip region and the text area.
SliderCDEF 1.2.1
----------------
• (6/21/94) Fixed drawing in black and white disabled controls. Minor improvements in dragging.
SliderCDEF 1.2.0
----------------
• (6/17/94) Complete rewrite of drawing algorithms for enhanced performance and bug fixing. No longer leaves a piece of the thumb behind when doing start-stop dragging. Removed vbl task stuff for compatiblilty. Drawing procedure now adds a frame around the entire control. Control values no longer jitter when dragging.
SliderCDEF 1.1.0
----------------
• (6/9/94) Added smarter depth control for the offscreen graphics world - 1 bit depth is used if the control's window isn't a CGrafPort. Fixed a bug that caused the control do be drawn improperly if the control's window wasn't visible at the time of its creation. The slider now restores the font characteristics of the port after drawing the control value.
• (6/8/94) Fixed calculation of control values for cases where control min is not zero.
• (3/12/94) Added smarter redrawing tested under changing monitor depths. Added disabled black and white drawing. Improved efficiency of the dragging routine.
• (3/11/94) Fixed numerous small drawing and behavioral bugs. Added test for inPageUp and inPageDown. Added comments and cleaned up the demo.
• (2/18/94) Added support for vertical sliders with values drawn along the right side of the control. Tried using fixed point math for calculation of control values but the value drawing became jumpy (maybe from not rounding properly).
• (2/13/94) The slider now uses DeviceLoop to do its drawing and will draw an all gray version when inactive.
• (2/12/94) Put all colors in the slider's data structure instead of a separate structure and initialized them during the initCtrl message. Added some error checking during initialization of the control (e.g. when creating the GWorld). Got rid of many uneccesary HLocks.
SliderCDEF 1.0.0
----------------
• (12/10/93) Initial release - posted to alt.sources.mac